axios.defaults.baseURL = 'http://www.liulongbin.top:3008'

axios.interceptors.request.use(function (config) {
  console.log(config)
  if (config.url.indexOf('/my') !== -1) {
    config.headers.Authorization = localStorage.getItem('token')
  }
  return config
}, function (error) {
  return Promise.reject(error)
})


axios.interceptors.response.use(function (response) {

  return response
}, function (error) {
  console.log(error.response)
  if (error.response.status === 401) {
    localStorage.removeItem('token')
    location.href = '/login.html'
  }
  return Promise.reject(error)
})
